package com.sunnada.edu.system.pub.securityFilter;

import java.util.HashMap;
import java.util.Map;

import org.springframework.util.StringUtils;

/**
 * 自动登录连接
 */
public class AutoLoginUrls {
	//自动登录连接
	private Map<String,String> autoLoginUrls = new HashMap<String,String>();
	
	public void setAutoLoginUrlList(String list){
		autoLoginUrls.putAll(parsetList(list,false));
	}
	
	public Map<String,String> getAutoLoginUrls() {
		return autoLoginUrls;
	}
	
	public void setAutoLoginUrls(Map<String,String> autoLoginUrls) {
		this.autoLoginUrls = autoLoginUrls;
	}
	
	private Map<String,String> parsetList(String str,boolean b){
		HashMap<String,String> map = new HashMap<String,String>(); 
		String[] tmp = StringUtils.tokenizeToStringArray(str, "; \t\n");
		String[] tmp2 = null;
		for(int i=0;i<tmp.length;i++){
			if(b){
				tmp2 = StringUtils.tokenizeToStringArray(tmp[i],"=");
				if(!tmp2[1].trim().endsWith(","))
					tmp2[1]=tmp2[1].trim()+",";
				map.put(tmp2[0],tmp2[1]);
			}else{
				map.put(tmp[i],"");
			}
		}
		return map;
	}
}
